/*
 * 文 件    名:  Banner.java
 * 创建日期:  2012-12-11下午3:17:40
 * 版          权:  Epro Technologies Co., Ltd. Copyright 2011-2012,  All rights reserved
 * 作          者:  yw66009
 */
package com.weipu.common.facade.model;

import java.io.Serializable;

import org.json.JSONObject;

import com.weipu.common.constants.ServerConstant;

/**
 * @Description 推广
 * @version [版本号, 2012-12-11]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 * 
 * @author yw66009
 */
public class BannerModel implements Serializable {
	/**
	 * @Fields serialVersionUID : 版本序列号
	 */
	private static final long serialVersionUID = -4343511016644922450L;

	private String bannerID;

	private String bannerImg;

	private String bannerName;

	// 0代表banner是产品列表类型 2代表Banner需要跳转主站URL
	private int LinkType;

	private String LinkUrl = "http://www.dx.com/";

	/**
	 * 手机图片
	 */
	private String BannerForPhone1242X663;

	/**
	 * (本地)广告数据更新时间，用于本地数据缓存，单位：毫秒
	 */
	public long cacheUpdateTime;

	public String getBannerID() {
		return bannerID;
	}

	public int getLinkType() {
		return LinkType;
	}

	public void setLinkType(int linkType) {
		LinkType = linkType;
	}

	public String getLinkUrl() {
		return LinkUrl;
	}

	public void setLinkUrl(String linkUrl) {
		LinkUrl = linkUrl;
	}

	public void setBannerID(String bannerID) {
		this.bannerID = bannerID;
	}

	public String getBannerImg() {
		return bannerImg;
	}

	public void setBannerImg(String bannerImg) {
		this.bannerImg = bannerImg;
	}

	public long getCacheUpdateTime() {
		return cacheUpdateTime;
	}

	public void setCacheUpdateTime(long cacheUpdateTime) {
		this.cacheUpdateTime = cacheUpdateTime;
	}

	public String getBannerName() {
		return bannerName;
	}

	public void setBannerName(String bannerName) {
		this.bannerName = bannerName;
	}

	public String getBannerForPhone1242X663() {
		return BannerForPhone1242X663;
	}

	public void setBannerForPhone1242X663(String bannerForPhone1242X663) {
		BannerForPhone1242X663 = bannerForPhone1242X663;
	}

	/**
	 * JSON对象转存到新闻model
	 * 
	 * @param json
	 * @return NewsCornerModel对象
	 * @return NewsCornerModel
	 * @exception throws [违例类型] [违例说明]
	 * @see [类、类#方法、类#成员]
	 */
	public static BannerModel json2BannerModel(JSONObject json) {
		BannerModel model = new BannerModel();
		if (null != json) {
			if (json.optString(ServerConstant.Banner.CONSTANT_BANNERID) != JSONObject.NULL
					&& !json.isNull(ServerConstant.Banner.CONSTANT_BANNERID)) {
				model.setBannerID(json
						.optString(ServerConstant.Banner.CONSTANT_BANNERID));
			}
			if (json.optString(ServerConstant.Banner.CONSTANT_BANNERIMG) != JSONObject.NULL
					&& !json.isNull(ServerConstant.Banner.CONSTANT_BANNERIMG)) {
				model.setBannerImg(json
						.optString(ServerConstant.Banner.CONSTANT_BANNERIMG));
			}
			if (json.optString(ServerConstant.Banner.CONSTANT_BANNERNAME) != JSONObject.NULL
					&& !json.isNull(ServerConstant.Banner.CONSTANT_BANNERNAME)) {
				model.setBannerName(json
						.optString(ServerConstant.Banner.CONSTANT_BANNERNAME));
			}
			if (json.optString(ServerConstant.Banner.BANNERFORPHONE1242X663) != JSONObject.NULL
					&& !json.isNull(ServerConstant.Banner.BANNERFORPHONE1242X663)) {
				model.setBannerForPhone1242X663(json
						.optString(ServerConstant.Banner.BANNERFORPHONE1242X663));
			}

			model.setLinkType(json
					.optInt(ServerConstant.Banner.CONSTANT_BANNE_LINKTYPE));

			if (json.optString(ServerConstant.Banner.CONSTANT_BANNE_LINKURL) != JSONObject.NULL
					&& !json.isNull(ServerConstant.Banner.CONSTANT_BANNE_LINKURL)) {
				model.setLinkUrl(json
						.optString(ServerConstant.Banner.CONSTANT_BANNE_LINKURL));
			}
		}

		return model;
	}

}
